﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MusicPlayerPlus.Core.Reflection.ActionParam
{
    public class ActionData
    {
        /// <summary>
        /// ActionParam 数据
        /// </summary>
        private static Dictionary<Type, object> ActionParam = new Dictionary<Type, object>();

        /// <summary>
        /// 添加参数
        /// </summary>
        /// <param name="type"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static bool AddParam(Type type, object obj)
        {
            if (ActionParam.ContainsKey(type))
            {
                return false;
            }
            ActionParam.Add(type, obj);
            return true;
        }
        /// <summary>
        /// 获取参数
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="type"></param>
        /// <returns></returns>
        public static T GetActionParam<T>(Type type) where T : class
        {
            if (!ActionParam.ContainsKey(type))
            {
                return null;
            }
            object obj = ActionParam[type];
            return obj as T;
        }
    }
}
